import java.util.StringTokenizer;

class P572_39643 {

    public static void main(String[] args) {
    	StringTokenizer st = new StringTokenizer(readLn());
    	int i = Integer.parseInt(st.nextToken());
    	int j = Integer.parseInt(st.nextToken());
    	
    	while (i != 0 && j != 0) {
    		process(i, j);
    		st = new StringTokenizer(readLn());
        	i = Integer.parseInt(st.nextToken());
        	j = Integer.parseInt(st.nextToken());
    	}
	}


	private static void process(int i, int j) {
		int[][] grid = new int[i][j];
		
		for (int k = 0; k < i; k++) {
			String line = readLn();
			for (int l = 0; l < j; l++) {
				char c = line.charAt(l);
				grid[k][l] = c == '@' ? -2 : c == '*' ? - 1 : 0;
			}
		}

//		print(grid);
		
		int counter = 0;
		
		for (int k = 0; k < i; k++) {
			for (int l = 0; l < j; l++) {
				if (grid[k][l] == -2) {
					counter++;
					floodfill(grid, k, l, counter);
				}
			}
		}
//		System.out.println("-----");
//		print(grid);
//		System.out.println("=======");
		
		System.out.println(counter);
	}

	private static void print(int[][] grid) {
		for (int k = 0; k < grid.length; k++) { 
			for (int j = 0; j < grid[k].length; j++) {
				System.out.print(grid[k][j]);
			}
			System.out.println();
		}
			
	}


	// @ == -2
	// * == -1
	private static void floodfill(int[][] grid, int i, int j, int counter) {
		if (i >= 0 && j >= 0 && j < grid[0].length && i < grid.length) { 
			int c = grid[i][j];
			if (c >= -1) return;
			if (c == -2)
				grid[i][j] = counter;
			
			floodfill(grid, i - 1, j, counter);
			floodfill(grid, i - 1, j + 1, counter);
			floodfill(grid, i - 1, j - 1, counter);
			floodfill(grid, i + 1, j, counter);
			floodfill(grid, i + 1, j + 1, counter);
			floodfill(grid, i + 1, j - 1, counter);
			floodfill(grid, i, j - 1, counter);
			floodfill(grid, i, j + 1, counter);
		}
	}


	static String readLn() {
        String newLine = System.getProperty("line.separator");
        StringBuffer buffer = new StringBuffer();
        int car = -1;
        try {
            car = System.in.read();
            while ((car > 0) && (car != newLine.charAt(0))) {
                buffer.append((char)car);
                car = System.in.read();
            }
            if (car == newLine.charAt(0))
            System.in.skip(newLine.length() - 1);
        } catch (java.io.IOException e) { return (null);}
        if ((car < 0) && (buffer.length() == 0)) return (null);
        return (buffer.toString()).trim();
    }

}